package com.library.service.impl;


import com.library.common.core.domain.BaseEntity;
import com.library.common.core.text.Convert;
import com.library.domain.MbSignRules;
import com.library.mapper.MbSignRulesMapper;
import com.library.service.IMbSignRulesService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 签到规则 服务层实现
 *
 * @author null
 * @date 2020-04-23
 * @blame Android Team
 */
@Service
public class MbSignRulesServiceImpl implements IMbSignRulesService {
    @Resource
    private MbSignRulesMapper mbSignRulesMapper;

    /**
     * 查询签到规则信息
     *
     * @param id 签到规则ID
     * @return 签到规则信息
     */
    @Override
    public MbSignRules selectMbSignRulesById(Long id) {
        return mbSignRulesMapper.selectMbSignRulesById(id);
    }

    /**
     * 查询签到规则列表
     *
     * @param mbSignRules 签到规则信息
     * @return 签到规则集合
     */
    @Override
    public List<MbSignRules> selectMbSignRulesList(MbSignRules mbSignRules) {
        return mbSignRulesMapper.selectMbSignRulesList(mbSignRules);
    }

    /**
     * 新增签到规则
     *
     * @param mbSignRules 签到规则信息
     * @return 结果
     */
    @Override
    public int insertMbSignRules(MbSignRules mbSignRules) {
        return mbSignRulesMapper.insertMbSignRules(mbSignRules);
    }

    /**
     * 修改签到规则
     *
     * @param mbSignRules 签到规则信息
     * @return 结果
     */
    @Override
    public int updateMbSignRules(MbSignRules mbSignRules) {
        return mbSignRulesMapper.updateMbSignRules(mbSignRules);
    }

    /**
     * 删除签到规则对象
     *
     * @param strings 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteMbSignRulesByIds(Long[] strings) {
        for (Long id : strings) {
            MbSignRules mbSignRules = mbSignRulesMapper.selectMbSignRulesById(id);
            if (null == mbSignRules)
                continue;
            mbSignRules.setIsDelete(BaseEntity.DELETE);
            mbSignRulesMapper.updateMbSignRules(mbSignRules);
        }
        return BaseEntity.DELETE;
    }

    @Override
    public List<MbSignRules> selectSignRulesAll() {
        MbSignRules mbSignRules = new MbSignRules();
        mbSignRules.setExt("累计签到");
        return mbSignRulesMapper.selectMbSignRulesList(mbSignRules);
    }

}
